package com.gandong8.es.web.domain.esindex;

import com.gandong8.es.tool.annotation.EsMapping;
import com.gandong8.es.tool.annotation.EsSetting;
import com.gandong8.es.tool.core.EsDoc;
import com.gandong8.es.tool.domain.EsAnalyzer;
import com.gandong8.es.tool.domain.EsDataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Date;

@EqualsAndHashCode(callSuper = true)
@EsSetting(provided_name = "test_index",
        number_of_replicas = 0,number_of_shards = 1,refresh_interval = "20s",
        merge_scheduler_max_thread_count = 1,index_date_format = "_yyyyMMdd")
@Data
@NoArgsConstructor
public class TestIndex extends EsDoc {
    private static final long serialVersionUID = -730655010049656727L;
    @EsMapping(document_id = true)
    private String id;
    @EsMapping(datatype = EsDataType.KEYWORD)
    private String path;
    @EsMapping(datatype = EsDataType.KEYWORD)
    private String env;
    @EsMapping(datatype = EsDataType.LONG)
    private Long cost;
    @EsMapping(datatype = EsDataType.TEXT, analyzer = EsAnalyzer.STOP, search_analyzer = EsAnalyzer.SIMPLE)
    private String result;
    @EsMapping(datatype = EsDataType.DATE, sort_time = true)
    private Date addTime;
    @EsMapping(datatype = EsDataType.DATE)
    private Date editTime;

    public TestIndex(String docId) {
        setDocumentId(docId);
    }

    @Override
    public String esDocumentId(){
        return getId();
    }

    @Override
    public void setDocumentId(String docId) {
        setId(docId);
    }


}
